<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

function creat_uri($uri, $sub_dir = '')
{
    $CI =& get_instance();
    
    if($sub_dir != '') {
        if(isset($uri['dir']) && $uri['dir'] != '') $uri['dir'] .= ':'.$sub_dir;

        else $uri['dir'] = $sub_dir;
    }
    
    return admin_url('image/index/'.$CI->uri->assoc_to_uri($uri));
}

function creat_path($uri, $item)
{    
    $path = str_replace(':', '/', $uri['dir']).'/'.$item;
    
    return site_url('uploads/'.$path);
}

function is_image($ext = '')
{
    $ext_arr = array('jpg', 'png', 'gif');
    
    if(in_array($ext, $ext_arr)) return true;
    else return false;
}

function is_document($ext = '')
{
    $ext_arr = array('doc', 'docx', 'pdf', 'xls', 'txt', 'zip', 'rar', 'rtf', 'csv', 'pps', 'ppt');

    if(in_array($ext, $ext_arr)) return true;
    else return false;
}

function is_video($ext = '')
{
    $ext_arr = array('flv', 'mp4');
    
    if(in_array($ext, $ext_arr)) return true;
    else return false;
}